<template>
  <div>
    <h2>活动修改</h2>
    <table>
      <tbody>
        <tr>
          <td>活动图片</td>
          <td><input type="file" /></td>
        </tr>
        <tr>
          <td>活动名称</td>
          <td><input type="text" v-model="form.hname"  /></td>
        </tr>
        <tr>
          <td>活动状态</td>
          <td><input  type="text" v-model="form.hzhuangtai" /></td>
        </tr>
        <tr>
          <td>活动分类</td>
          <td><input type="text" v-model="form.hfenlei" /></td>
        </tr>
        <tr>
          <td>地址</td>
          <td><input type="text" v-model="form.hadder" /></td>
        </tr>
        <tr>
          <td></td>
          <td><button class="btn btn-primary" @click="Add">修改</button></td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import axios from "axios";
import { textChangeRangeIsUnchanged } from "typescript";
import { ref, reactive, onMounted } from "vue";
import { useRoute } from "vue-router";

const form = reactive({
  id: 0,
  hname: "",
  hzhuangtai: "",
  hfenlei: "",
  hadder: "",
  imgin: "",
});

const Add = () => {
  if (form.hname == "") {
    alert("活动名称不能为空");
    return;
  }
  if (form.hzhuangtai == "") {
    alert("活动状态不能为空");
    return;
  }
  if (form.hname == "") {
    alert("活动分类不能为空");
    return;
  }
  if (form.hname == "") {
    alert("活动地址不能为空");
    return;
  }
  axios.post("https://localhost:7010/api/huodong/Addhuo", form).then((res) => {
    if (res.data > 0) {
      alert("修改成功");
      return;
    } else {
      alert("修改失败");
      return;
    }
  });
};
</script>

<style scoped></style>
